// -*-c++-*- osgCairo - Copyright (C) 2010 Jeremy Moles
// $Id$

#ifndef OSGCAIRO_MATRIX
#define OSGCAIRO_MATRIX

#include <ostream>
#include <osg/Referenced>
#include <osgCairo/Types>

namespace osgCairo {

class OSGCAIRO_EXPORT Matrix: public CairoMatrix, public osg::Referenced {
public:
	Matrix  (double=0.0f, double=0.0f, double=0.0f, double=0.0f, double=0.0f, double=0.0f);
	Matrix  (const CairoMatrix&);
	~Matrix ();

	Matrix operator= (const Matrix&);
	Matrix operator* (const Matrix&);
	
	// These modify the matrx "in place."
	void setTranslate      (double, double);
	void setScale          (double, double);
	void setRotate         (double);
	void invert            ();
	void transformDistance (double*, double*);
	void transformPoint    (double*, double*);
	
	// These create new matrices.
	static Matrix identity  ();
	static Matrix translate (double, double);
	static Matrix scale     (double, double);
	static Matrix rotate    (double);
};

inline std::ostream& operator<<(std::ostream& output, const Matrix& m) {
	output
		<< m.xx << " " << m.yx << std::endl
		<< m.xy << " " << m.yy << std::endl
		<< m.x0 << " " << m.y0 << std::endl
	;

	return output;
}

}

#endif
